﻿package mortal.game.view.guild.tabpanel
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.cache.guild.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.guide.*;
    import mortal.game.view.guild.cellrender.*;
    import mortal.mvc.core.*;

    public class GuildSkillPanel extends GuildBasePanel
    {
        private var _bmpTxtSchoolLevel:BitmapNumberText;
        private var _txtSchoolName:GTextFiled;
        private var _bmpBigBuilding:GImageBitmap;
        private var _list:GTileList;
        private var _txtMyContribute:GTextFiled;
        private var _txtLearnAmont:GTextFiled;

        public function GuildSkillPanel()
        {
            super(ResFileConst.guildOtherPanel);
            return;
        }// end function

        private function onAutoGuideRedPointRefresh(event:DataEvent) : void
        {
            this.update();
            return;
        }// end function

        override public function layoutUI() : void
        {
            super.layoutUI();
            UIFactory.bg(18, 69, 227, 450, this, ImagesConst.guildInfoBg);
            UIFactory.gBitmap(ImagesConst.guildLevelBg, 50, 86, this);
            this._bmpTxtSchoolLevel = UIFactory.bitmapNumberText(129, 112, "StrengthenNumber.png", 32, 40, -6, this, 13, BitmapNumberText.Mid);
            this._bmpTxtSchoolLevel.text = "24";
            var _loc_1:* = GlobalStyle.textFormatItemGreen;
            _loc_1.align = "center";
            this._txtSchoolName = UIFactory.gTextField("", 58, 182, 150, 24, this, _loc_1);
            this._txtSchoolName.text = GuildConst.getBuildingNameByType(EGuildStructureType._EGuildSchool);
            this._bmpBigBuilding = UIFactory.gImageBitmap(ImagesConst.GuildBuilding_Big_1, 25, 277, this);
            UIFactory.bg(250, 67, 470, 450, this);
            this._list = UIFactory.tileList(257, 73, 470, 410, this);
            this._list.rowHeight = 80;
            this._list.columnWidth = 220;
            this._list.setStyle("cellRenderer", GuildSkillListCellRenderer);
            UIFactory.textField("" + Language.getString(71338), 260, 490, 80, 22, this);
            this._txtMyContribute = UIFactory.textField("", 320, 490, 85, 22, this);
            UIFactory.textField("" + Language.getString(71339), 430, 490, 70, 22, this);
            this._txtLearnAmont = UIFactory.textField("", 500, 490, 70, 22, this);
            Dispatcher.addEventListener(EventName.AutoGuideRedPointRefresh, this.onAutoGuideRedPointRefresh);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            Dispatcher.removeEventListener(EventName.AutoGuideRedPointRefresh, this.onAutoGuideRedPointRefresh);
            return;
        }// end function

        override public function update() : void
        {
            super.update();
            var _loc_1:* = Cache.instance.guild.selfGuildInfo;
            this._bmpTxtSchoolLevel.text = _loc_1.baseInfo.level.toString();
            this._txtMyContribute.text = _loc_1.selfInfo.contribution.toString();
            this._txtLearnAmont.text = _loc_1.selfInfo.skillTimes + "/" + GuildConst.GuildSkillLearnCount();
            AutoGuideRedPoint2.isSkillFull = _loc_1.selfInfo.skillTimes == 0;
            var _loc_2:* = GuildBuildingConfig.instance.getInfoByBuildingType(_loc_1.baseInfo.level, EGuildStructureType._EGuildSchool).structureLevel;
            var _loc_3:* = GuildSchoolConfig.instance.getInfoByLevel(_loc_2);
            var _loc_4:Array = [];
            if (_loc_3.skillLife > 0)
            {
                _loc_4.push(_loc_3.skillLife);
            }
            if (_loc_3.skillAttack > 0)
            {
                _loc_4.push(_loc_3.skillAttack);
            }
            if (_loc_3.skillToughness > 0)
            {
                _loc_4.push(_loc_3.skillToughness);
            }
            if (_loc_3.skillCrit > 0)
            {
                _loc_4.push(_loc_3.skillCrit);
            }
            if (_loc_3.skillHit > 0)
            {
                _loc_4.push(_loc_3.skillHit);
            }
            if (_loc_3.skillJouk > 0)
            {
                _loc_4.push(_loc_3.skillJouk);
            }
            if (_loc_3.skillDefense > 0)
            {
                _loc_4.push(_loc_3.skillDefense);
            }
            if (_loc_3.skillPenetration > 0)
            {
                _loc_4.push(_loc_3.skillPenetration);
            }
            if (_loc_3.skillExpertise > 0)
            {
                _loc_4.push(_loc_3.skillExpertise);
            }
            if (_loc_3.skillBlock > 0)
            {
                _loc_4.push(_loc_3.skillBlock);
            }
            this._list.dataProvider = new DataProvider(_loc_4);
            return;
        }// end function

        override public function onMouseClick(event:MouseEvent) : void
        {
            super.onMouseClick(event);
            return;
        }// end function

    }
}
